package com.njtoyo.taxi.admin.rest.controller.open;

import com.njtoyo.taxi.admin.aop.LoggerManage;
import com.njtoyo.taxi.admin.aop.PassToken;
import com.njtoyo.taxi.admin.rest.wrapper.open.notification.BigOrderWrapper;
import com.njtoyo.taxi.admin.rest.wrapper.open.notification.CustomerLogoutWrapper;
import com.njtoyo.taxi.admin.rest.wrapper.open.notification.DriverCertificateExpirationWrapper;
import com.njtoyo.taxi.admin.rest.wrapper.open.notification.DriverRegisterNotificationWrapper;
import com.njtoyo.taxi.admin.service.open.NotificationService;
import com.taxi.entity.common.RestResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/open/notification")
@Api(tags = "通知相关")
public class NotificationController {

    @Autowired
    private NotificationService notificationService;

    @PostMapping("/customer_logout")
    @ApiOperation(value = "乘客注销通知", notes = "乘客申请注销时发起通知，公共接口，无权限校验")
    @LoggerManage(description = "乘客注销通知")
    @PassToken
    public RestResult customerLogout(@Valid @RequestBody CustomerLogoutWrapper wrapper) throws WxErrorException {
        return notificationService.customerLogout(wrapper);
    }

    @PostMapping("/big-order")
    @ApiOperation(value = "大额订单通知", notes = "大额订单通知，公共接口，无权限校验")
    @LoggerManage(description = "大额订单通知")
    @PassToken
    public RestResult bigOrder(@Valid @RequestBody BigOrderWrapper wrapper) throws WxErrorException {
        return notificationService.bigOrder(wrapper);
    }

    @PostMapping("/driver-register")
    @ApiOperation(value = "司机注册通知", notes = "司机注册通知，公共接口，无权限校验")
    @LoggerManage(description = "司机注册通知")
    @PassToken
    public RestResult driverRegister(@Valid @RequestBody DriverRegisterNotificationWrapper wrapper) throws WxErrorException {
        return notificationService.driverRegister(wrapper);
    }

    @PostMapping("/driver-audit-certificate")
    @ApiOperation(value = "司机证件更新审核通知", notes = "司机证件更新审核通知，公共接口，无权限校验")
    @LoggerManage(description = "司机证件更新审核通知")
    @PassToken
    public RestResult driverAuditCertificate(@Valid @RequestBody DriverCertificateExpirationWrapper wrapper) throws WxErrorException {
        return notificationService.driverAuditCertificate(wrapper);
    }
}
